package com.csr.csrcheck.config;

import com.csr.csrcheck.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;
import org.springframework.web.servlet.HandlerInterceptor;

import java.util.ArrayList;
import java.util.List;


/**
 * @Description: 登陆拦截器
 * @author caojide
 * @date 2020-08-17 20:26
 */
@Configuration
public class LoginInterceptorConfigurer implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        System.out.println("addInterceptors");
        LoginInterceptor loginInterceptor = new LoginInterceptor();
        List<String> paths = new ArrayList<String>();
        paths.add("/js/**");
        paths.add("/css/**");
        paths.add("/images/**");
        paths.add("/img/**");
        paths.add("/upload/**");
        paths.add("/fonts/**");
        paths.add("/bootstrap3/**");
        paths.add("/districts/**");
        paths.add("/web/login.html");
        paths.add("/users/login");
        paths.add("/users/img");
        paths.add("/users/img");
        paths.add("/company/companylist");
        paths.add("/company/companylist2");
        paths.add("/news/newlist");
        paths.add("/feeedback/add");
        paths.add("/news/byidnews/{id}");
        paths.add("/flight_check/flight_checkllist");
        paths.add("/clinic/cliniclist");
        paths.add("/approvals/approvalslist");
        paths.add("/evaluate/evaluatelist");
        paths.add("/flight_check/flight_checkllist2");
        paths.add("/military/militarylist");
        paths.add("/military/militarylist2");
        paths.add("/flight_check/flight_checkllist3");
        paths.add("/actual_controller/actual_controllerlist");
        paths.add("/contend/contendlist");
        paths.add("/organ/organlist");
        paths.add("/organ/organlist2");
        paths.add("/lawsuit/lawsuitlist");
        paths.add("/business_risks/business_riskslist");
        paths.add("/Instrument_bulletin/Instrument_bulletinlist");
        paths.add("/Instrument_bulletin/Abnormal_productslist");
        paths.add("/guide/guidelist");
        paths.add("/research/researchlist");
        paths.add("/industry/industrylist");
        paths.add("/exponent/exponentlist");
        paths.add("/other/otherlist");
        paths.add("/speech/speechlist");
        paths.add("/enabled/enabledlist");
        paths.add("/com_news/news");
        paths.add("/ecosphere/five_suplier");
        paths.add("/their/domestic");
        paths.add("/their/theirlist");
        paths.add("/military/medical");
        paths.add("/military/legitimate");
        paths.add("/ecosphere/alteration");
        paths.add("/their/Notification");
        paths.add("/company/special");
        paths.add("/abnormal/product");
        paths.add("/their/company");
        paths.add("/their/import");
        paths.add("/news/newlist");
        paths.add("/patent/patentlist");
        paths.add("/recall/recalllist");
        registry.addInterceptor((HandlerInterceptor)loginInterceptor).addPathPatterns(new String[] { "/**" }).excludePathPatterns(paths);
    }
}
